<template>
  <div class="com-header">
    <div class="menu">
      <nav class="menu-nav" :class="{'active':showMenu}">
        <nuxt-link class="nav-item" to="/">
          <span class="icon kkIcon-home"></span>
          <span class="name">首页</span>
        </nuxt-link>
        <nuxt-link class="nav-item" to="/article">
          <span class="icon kkIcon-collect"></span>
          <span class="name">笔记</span>
        </nuxt-link>
        <nuxt-link class="nav-item" to="/photos">
          <span class="icon kkIcon-picture"></span>
          <span class="name">吸猫</span>
        </nuxt-link>
        <nuxt-link class="nav-item" to="/about">
          <span class="icon kkIcon-people"></span>
          <span class="name">了解我</span>
        </nuxt-link>
        <span></span>
      </nav>
      <div class="menu-icon" :class="{'active':showMenu}" @click="menuToggle">
        <span></span>
        <span></span>
        <span></span>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data(){
    return {
      showMenu:false
    }
  },
  methods: {
    menuToggle(){
      this.showMenu = !this.showMenu;
    }
  },
}
</script>
<style lang="less">
html, body {
	position: relative;
	height: 100%;
}
body {
	background: #333;
	font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
	font-size: 14px;
	color: #333;
	margin: 0;
	padding: 0;
	overflow: hidden;
}
.com-header{
  position: absolute;
  top: 0;
  left: 0;
  width:100%;
	height: 6vw;
	display: flex;
	justify-content: flex-end;
	align-items: center;
  
}
.menu{
  display: flex;
  justify-content: flex-end;
  align-items: center;
  position: relative;

  z-index: 3;
}

.menu-nav{
  width:0;
  height: 42px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.4);
  border: none;
  border-radius: 25px;
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  align-items: center;
  position: relative;
  transition: all 0.6s ease-in-out;
  overflow: hidden;
  box-shadow: 3px 3px 3px 3px rgba(0,0,0,0.4); 
}
.menu-nav.active{
  padding:0 4px;
  box-sizing: border-box;
  width:408px;
}
.menu-nav .nav-item {
  position: relative;
  text-decoration: none;
  color: #53588b;
  font-family: Verdana, Geneva, Tahoma, sans-serif;
  font-size: 12px;
  line-height: 1;
  text-align: center;
  display: inline-block;
  width: 100px;
  box-sizing: border-box;
  z-index: 2;
}

.menu-nav .nav-item .name {
  position: absolute;
  width:60px;
  text-align: center;
  font-size: 16px;
  top: 40px;
  left: 32px;
  color: #999999;
  transition: 0.3s ease top;
}

.menu-nav .nav-item .icon {
  font-size: 24px;
  font-weight: bold;
  position: absolute;
  color: #999999;
  left: calc(50% - 12px);
  top: 0;
  transition: 0.3s ease left;
}
.menu-nav .nav-item{
  position: relative;
  width:100px;
  height: 36px;
  line-height: 36px;
}
.menu-nav>span {
  position: absolute;
  width: 100px;
  background-color: #e5eeff;
  top: 4px;
  bottom: 4px;
  left: 4px;
  border-radius: 50px;
  z-index: 1;
  transition: 0.3s ease left;
}
.menu-nav .nav-item:hover .name,
.menu-nav .nav-item.nuxt-link-exact-active .name {
  top: 0;
  color: #000000;
}

.menu-nav .nav-item:hover .icon,
.menu-nav .nav-item.nuxt-link-exact-active .icon {
  left: 10px;
  color: #000000;
}
.menu-nav .nav-item:nth-child(1).nuxt-link-active ~ span {
  left: 4px;
}
.menu-nav .nav-item:nth-child(2).nuxt-link-active ~ span {
  left: 104px;
}
.menu-nav .nav-item:nth-child(3).nuxt-link-active ~ span {
  left: 204px;
}
.menu-nav .nav-item:nth-child(4).nuxt-link-active ~ span {
  left: 304px;
}
.menu-nav .nav-item:nth-child(1):hover ~ span{
  left: 4px;
}
.menu-nav .nav-item:nth-child(2):hover ~ span{
  left: 104px;
}
.menu-nav .nav-item:nth-child(3):hover ~ span {
  left: 204px;
}
.menu-nav .nav-item:nth-child(4):hover ~ span{
  left: 304px;
}

.menu-icon{
  margin: 8px 50px 0 20px;
  cursor: pointer;
  position: relative;
  width:42px;
  height:42px;
  padding: 0px;
  background-color:transparent;
  border-style:none;
  outline: none;
  cursor: pointer;
}
.menu-icon span{
  width:100%;
  height:5px;
  background-color:#fff;
  display:block;
  position: absolute;
  border-radius: 2px;
  transition: all .5s ease;
}
.menu-icon span:nth-child(1){
    top:0px;
    left:0px;
}
.menu-icon span:nth-child(2){
    top:12px;
    right:0px;
}
.menu-icon span:nth-child(3){
    top:28px;
    left:0px;
}
.menu-icon.active span:nth-child(2){
    animation: span2 .5s forwards cubic-bezier(.8, .5, .2, 1.4);
}
@keyframes span2{
    0%{
        transform: translate(0,0) scale(1);
    }
    20%{
        width:5px;
        border-radius: 50%;
        transform: translate(0,0) scale(1);
    }
    40%{
        width:5px;
        border-radius: 50%;
        transform: translate(0,0) scale(1);
    }
    50%{
        width:5px;
        border-radius: 50%;
        transform: translate(0,10px) scale(1); 
    }
    80%{
        width:5px;
        border-radius: 50%;
        transform: translate(0,-16px) scale(1);
    }
    100%{
        width:5px;
        border-radius: 50%;
        transform: translate(0,100px) scale(0);
    }
}
.menu-icon.active span:nth-child(3){
    animation: span3 .3s forwards cubic-bezier(.8, .5, .2, 1.4);
    animation-delay: .2s;
}
@keyframes span3{
    0%{
        transform: translate(0,0);
    }
    60%{
        transform: rotate(80deg) translate(-10px, -10px);
    }
    100%{
        transform: rotate(45deg) translate(-10px, -10px);
    }
}
.menu-icon.active span:nth-child(1){
    animation: span1 .3s forwards cubic-bezier(.8, .5, .2, 1.4);
    animation-delay: .4s;
}
@keyframes span1{
    0%{
        transform: translate(0,0);
    }
    60%{
        transform: rotate(-110deg) translate(-10px, -10px);
    }
    100%{
        transform: rotate(-45deg) translate(-10px, 10px);
    }
}   
.menu-icon span:nth-child(1){
    animation: span1_close .2s forwards cubic-bezier(.8, .5, .2, 1.4);
}
@keyframes span1_close {
    0%{
        transform: rotate(-45deg) translate(-10px, 10px);
    }
    100%{
        transform: rotate(0deg) translate(0, 0);
    }
}
.menu-icon span:nth-child(2){
    animation: span2_close .2s forwards cubic-bezier(.8, .5, .2, 1.4);
}
@keyframes span2_close{
    0%{
        transform: translate(0, 40px) scale(0);
    }
    100%{
        transform: translate(0, 0) scale(1);
    }
}
.menu-icon span:nth-child(3){
    animation: span3_close .2s forwards cubic-bezier(.8, .5, .2, 1.4);
}
@keyframes span3_close{
    0%{
        transform: rotate(45deg) translate(-7px, -7px);
    }
    100%{
        transform: rotate(0deg) translate(0, 0);
    }
}

</style>
